////////////////////////////////////////////////////////////////////////////
//
//  Crytek Engine Source File.
//  Copyright (C), Crytek Studios, 2002.
// -------------------------------------------------------------------------
//  File name:   ReverbManagerEAX.h
//  Version:     v1.00
//  Created:     15/8/2005 by Tomas.
//  Compilers:   Visual Studio.NET
//  Description: EAX implementation of a ReverbManager.
// -------------------------------------------------------------------------
//  History:
//
////////////////////////////////////////////////////////////////////////////

#ifndef __REVERBMANAGEREAX_H__
#define __REVERBMANAGEREAX_H__

#include "ReverbManager.h"

#ifdef SOUNDSYSTEM_USE_FMODEX400
#include <FmodEx/inc/fmod_event.hpp>
#endif // SOUNDSYSTEM_USE_FMODEX400

struct IAudioDevice;

class CReverbManagerEAX : public CReverbManager
{

public:
	CReverbManagerEAX(void);
	~CReverbManagerEAX(void);

	//////////////////////////////////////////////////////////////////////////
	// Initialization
	//////////////////////////////////////////////////////////////////////////

	void Init(IAudioDevice* pAudioDevice, CSoundSystem* pSoundSystem);
	bool SelectReverb(int nReverbType);

	void Release();
	VIRTUAL void Reset();

	//////////////////////////////////////////////////////////////////////////
	// Information
	//////////////////////////////////////////////////////////////////////////

	// writes output to screen in debug
	void DrawInformation(IRenderer* pRenderer, float xpos, float ypos);

	// Draws the ray cast lines plus spheres at the collision points
	virtual void	DrawDynamicReverbDebugInfo(IRenderer* const pRenderer);

	//////////////////////////////////////////////////////////////////////////
	// Management
	//////////////////////////////////////////////////////////////////////////

	// needs to be called regularly
	VIRTUAL void Update(bool const bInside);
	VIRTUAL void TogglePause(bool const bPause);

private:

#ifdef SOUNDSYSTEM_USE_FMODEX400
	void             CreateEchoDSP();
	void             RemoveEchoDSP();
	FMOD::DSP* const FindReverbUnit();

	FMOD_RESULT		m_ExResult;
	FMOD::DSP*		m_pDSPEchoUnit;

	//cached reverb params (avoid unnecessary calls to set param)
	float m_fDelay;
	float m_fDecayRatio;
	float m_fDryMix;
	float m_fWetMix;

	static const float UPDATE_THRESHOLD;

	void CreateFMODReverbProperties(CRYSOUND_REVERB_PROPERTIES const& rCrySoundReverbProperties, FMOD_REVERB_PROPERTIES& rFMODReverbProperties) const;
#endif // SOUNDSYSTEM_USE_FMODEX400
};
#endif